#lang racket

;;;求解一个集合的子集
(define subsets
  (lambda (s)
    (if (null? s)
        (list null)
        (let ((rest (subsets (cdr s))))
          (append rest (map (lambda (x)
                              (cons (car s) x)) rest))))))
(subsets '(1 2 3))


;;;let是lambda的语法糖衣
(define subsets
  (lambda (s)
    (if (null? s)
        (list null)
        ((lambda (rest)
          (append rest (map (lambda (x)
                              (cons (car s) x)) rest)))
         (subsets (cdr s))))))
(subsets '(1 2 3))
